<template>
  <div class="page page-role">
    <c-content
      :page.sync="pages.page"
      :limit.sync="pages.limit"
      :totalRow.sync="pages.totalRow"
      @pagination="pageChange"
    >
      <!-- 查询 -->
      <el-form
        slot="search"
        :inline="true"
        class="search-form"
        label-width="100px"
        @submit.native.prevent
      >
        <!-- <el-form-item class="search-btn">
          <el-button v-waves type="primary" @click="openXM" size="mini"
            >新增</el-button
          >
        </el-form-item> -->
        <!-- <el-form-item label="检测特征名称">
          <el-input
            v-model="form.name"
            placeholder="请输入检测特征名称"
            clearable
            @keyup.enter.native="getList()"
            @clear="getList()"
          />
        </el-form-item> -->
      </el-form>
      <!-- 展示 -->
      <el-table
        slot="table"
        ref="multipleTable"
        v-loading="tab_loading"
        width="100%"
        border
        :data="dataList"
        class="expand--table"
      >
        <el-table-column align="center" prop="id" label="ID" />
        <!-- <el-table-column align="center" prop="featureId" label="顺序的被测参数号" /> -->
        <!-- <el-table-column align="center" prop="partId" label="顺序的零件号" /> -->
        <el-table-column align="center" prop="type" label="警报类型">
          <template slot-scope="scope">
            {{types[scope.row.type]}}
          </template>
        </el-table-column>
        <el-table-column align="center" prop="jobNos" label="工号" />
        <el-table-column align="center" prop="message" label="消息内容" />
        <!-- <el-table-column align="center" label="操作">
          <template slot-scope="scope">
            <c-button>
              <span @click="openXM(scope.row)">编辑</span>
              <span @click="handleDel(scope.row)" class="danger">删除</span>
            </c-button>
          </template>
        </el-table-column> -->
      </el-table>
    </c-content>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import { getLogCloud } from "../../api/job";
import AddEdit from "./XM/AddEditJob";
export default {
  components: {
    CContent: () => import("@/components/CContent"),
    // CButton: () => import('@/components/CButton')
  },
  computed: {
    ...mapGetters(["btn_permission"]),
  },
  props: {
    layerid: {
      default: 0,
    },
  },
  data() {
    return {
      tab_loading: false,
      pages: this.$mpages,
      types: {
        '1':'控制限',
        '2':'公差限',
        '3':'报废限'
      },
      form: {},
      dataList: [],
    };
  },
  created() {
    this.$getReset();
    this.getList();
  },
  methods: {
    /* 查询 */
    async getList() {
      const obj = JSON.parse(JSON.stringify(this.form));
      Object.assign(obj, this.pages);
      this.tab_loading = true;
      const { data } = await getLogCloud(obj);
      this.tab_loading = false;
      this.dataList = data.data;
      this.pages.totalRow = data.totalRow;
    },
    /* 删除 */
    // handleDel(row) {
    //   this.$confirm('确认删除此信息?', '提示', {
    //     confirmButtonText: '确认',
    //     cancelButtonText: '取消',
    //     type: 'warning'
    //   }).then(async () => {
    //     const res = await deleteFeatures(row.id)
    //    if (res.status == 200) {
    //       this.$message({ message: '删除成功', type: 'success' })
    //       this.getList()
    //    }
    //   }).catch(() => {
    //   })
    // },
    /* 添加和编辑 */
    openXM(row) {
      this.$layer.iframe({
        shadeClose: false,
        content: {
          content: AddEdit,
          parent: this,
          data: { row: row },
        },
        maxmin: true,
        area: ["600px", "500px"],
        title: row.id ? "修改消息配置" : "新增消息配置",
      });
    },
    /* 页码改变 */
    pageChange(param) {
      if (param.type === "index") this.pages.page = param.val;
      if (param.type === "sizes") this.pages.pagesize = param.val;
      this.getList();
    },
  },
};
</script>

<style lang="scss" scoped>
</style>

